<template>
  <main class="container">
    <van-cell-group inset>
      <van-field
        v-model="username"
        required
        label="用户名"
        placeholder="请输入用户名"
      />

      <van-field
        v-model="password"
        required
        type="password"
        label="密码"
        placeholder="请输入密码"
      />
    </van-cell-group>
    <div class="button-view">
      <van-button type="primary" block @click="handleLogin">登录</van-button>
    </div>
  </main>
</template>

<script setup>
import { ref } from "vue";
import { useUserStore } from "@/store";
const { setToken } = useUserStore();
import { useRouter, useRoute } from "vue-router";
const router = useRouter();
const route = useRoute();
const username = ref("test");
const password = ref("test");
const handleLogin = () => {
  setToken("token-123456789");
  router.replace({ path: route.query?.redirect || "/" });
};
</script>
<style scoped lang="scss">
.container {
  .button-view {
    margin-top: 40px;
  }
}
</style>
